/*
 * 自機コントロール
 */
void
shipcontrol()
	{
	int		i,a,b;

	if ( ship.flag == 0 ) return;

	// 爆発中の処理
	if ( ship.flag > 1 )
		{
		ship.flag++;
		if ( ship.flag > 9 )
			{
			os.geometryTop = cube1;
			os.geometryLength = sizeof(cube1) / sizeof(int);
			os.material = NULL;
			ship.flag = 1;
			mutekicount = 50;
			ship.hp--;
			// HPが0になったらGAME OVER
			if ( ship.hp < 0 )
				{
				ship.hp = 0;
				ship.flag = 0;
				deadcount++;
				}
			}
		return;
		}

	// 通常の処理
	get_pad();
	// 方向キーの上下
	if ( pad00.KD_DAT & KP_up )
		{
		ship.zspeed += 2;
		if ( ship.zspeed > MAXSPEED ) ship.zspeed = MAXSPEED;
		}
	else if ( pad00.KD_DAT & KP_down )
		{
		ship.zspeed -= 2;
		if ( ship.zspeed < MINSPEED ) ship.zspeed = MINSPEED;
		}
	// 方向キーの左右
	if ( pad00.KD_DAT & KP_right )
		{
		ship.x -= ship.xspeed;
		if ( ship.x < 0 ) ship.x = 0;
		if ( ship.deg < 0 ) ship.deg = 0;
		ship.deg++;
		if ( ship.deg > 15 ) ship.deg = 15;
		}
	else if ( pad00.KD_DAT & KP_left )
		{
		ship.x += ship.xspeed;
		if ( ship.x > FSX ) ship.x = FSX;
		if ( ship.deg > 0 ) ship.deg = 0;
		ship.deg--;
		if ( ship.deg < -15 ) ship.deg = -15;
		}
	else
		{
		if ( ship.deg > 0 ) ship.deg--;
		if ( ship.deg < 0 ) ship.deg++;
		}

	if ( bossflag ) ship.zspeed = MAXSPEED;

	// スコア加算
	if ( !bossflag && ship.y <= SHIPY )
		{
		ship.score += ship.zspeed*ship.zspeed/200;
		}

	// 一時停止
	if ( pad00.KD_TRG & KP_run ) pauseflag = 1;

	// 自弾発射
	if ( pad00.KD_TRG & KP_1 ) mslinit();

	// ジャンプ
	if ( pad00.KD_TRG & KP_2 && ship.yspeed >= -8 && ship.yspeed <= 0)
		{
		ship.yspeed = 30;
		}
	else
		{
		ship.yspeed -= 3;
		if ( ship.y <= SHIPY ) ship.yspeed = 0;
		}
	ship.y += ship.yspeed;
	if ( ship.y < SHIPY ) ship.y = SHIPY;
	if ( ship.y > FSY ) ship.y = FSY;

	if ( mutekicount ) return;

	// 敵との当たり判定
	for ( i = 0 ; i < MAXENEMY ; i++ )
		{
		if ( enemy[i].flag )
			{
			if ( hitcheck(i) )
				{
				PcmPlay(1,ADP_BBAKU);
				ship.flag = 2;
				os.geometryTop = cube3;
				os.geometryLength = sizeof(cube3) / sizeof(int);
				os.material = NULL;
				enemy[i].hp--;
				if ( enemy[i].hp <= 0 )
					{
					enemy[i].flag = 2;
					oe[i].geometryTop = cube3;
					oe[i].geometryLength = sizeof(cube3) / sizeof(int);
					oe[i].material = NULL;
					}
				}
			}
		}

	// 敵弾との当たり判定
	for ( i = 0 ; i < MAXEMSL ; i++ )
		{
		if ( emsl[i].flag )
			{
			if ( emslhitcheck(i) )
				{
				PcmPlay(1,ADP_BBAKU);
				ship.flag = 2;
				os.geometryTop = cube3;
				os.geometryLength = sizeof(cube3) / sizeof(int);
				os.material = NULL;
				emsl[i].flag = 0;
				}
			}
		}
	}
